Class ConnectedComponentsDFS

  • All Implemented Interfaces:
    Processable<Graph,​Graph>

    public class ConnectedComponentsDFS
    extends Algorithm
    Processes a Graph searching for connected components by performing a depth first search on each node.
    • Constructor Detail

      • ConnectedComponentsDFS

        public ConnectedComponentsDFS​(ArgumentsBundle bundle)
        Public constructor for initializing the DepthFirstTraversalSearch with default conditions.
        Parameters:
        bundle - the ArgumentsBundle containing the instantiation arguments.
    • Method Detail

      • process

        public java.util.ArrayList<Graph> process​(Graph graph)
        Processes data.
        Finds most Subgraphs by performing a depth first search on the node tree. It is unknown if it finds all or only most of the subgraphs due to the nature of the algorithm. It is expected, however, that it would miss certain node groupings.
        Parameters:
        graph - the Graph object to search through.
        Returns:
        the ArrayList of Graph objects holding all found subgraphs.
      • getConnectedComponents

        private java.util.ArrayList<Graph> getConnectedComponents​(Graph graph)
        Gets a list of this Graph's Connected Components. Uses Depth First Search Technique
        Returns:
        the list of this Graph's Connected Components
      • dfs

        private void dfs​(Node n,
                         java.util.List<Node> inodes,
                         java.util.List<Node> onodes,
                         Graph orig)
        Recursive dfs that stores the nodes of a connected component.
        Parameters:
        n - the starting node
        inodes - the nodes awaiting consideration
        onodes - the list of nodes to store the nodes of the connected components
        orig - original graph (should be undirected)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object